package com.itheima02;

import java.util.concurrent.CountDownLatch;

public class Test02 {
    public static void main(String[] args) {
        CountDownLatch count = new CountDownLatch(3);

        new Thread(() -> {

            try {
                count.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("妈妈在收拾碗筷");

        }, "妈妈").start();

        new Thread(() -> {

            for (int i = 1; i <= 10; i++) {
                System.out.println("小明在吃第" + i + "个饺子");
            }
            count.countDown();
        }, "小明").start();

        new Thread(() -> {

            for (int i = 1; i <= 15; i++) {
                System.out.println("小张在吃第" + i + "个饺子");
            }
            count.countDown();
        }, "小张").start();


        new Thread(() -> {

            for (int i = 1; i <= 20; i++) {
                System.out.println("小李在吃第" + i + "个饺子");
            }
            count.countDown();
        }, "小李").start();
    }
}
